﻿<c:WindowExt  x:Class="personalplaner.gui.stamm.windows.AddPersonToSchema"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:bs="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
        xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
        xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
        xmlns:p="clr-namespace:personalplaner.gui.Properties"
        xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
        xmlns:fac="clr-namespace:personalplaner.gui.stamm.viewmodels.factories"
        vm:ViewModelLoader.FactoryType="{x:Type fac:AddPersonToSchemaFactory}"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"
        Height="650" Width="900" Foreground="#E1000000">

    <Window.Resources>
       
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--<ResourceDictionary Source="/personalplaner.common;component/resources/TabControlStyles.xaml"/>-->
                <ResourceDictionary Source="/personalplaner.common;component/resources/styles/WhiteStyleTemplates.xaml"/>
                <ResourceDictionary>
                    <conv:BoolInvertConverter x:Key="boolInvert"/>
                    <conv:BoolToInvertVisibilityConverter x:Key="boolInvertVis"/>
                    <BooleanToVisibilityConverter x:Key="boolVis"/>
                    
                    <Style TargetType="Image" x:Key="imageStyle">
                        <Style.Triggers>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter Property="Opacity" Value="0.5"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

                    <DataTemplate DataType="{x:Type bs:Person}">
                        <Grid Margin="0,0,20,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Name="txtPrsId" Text="{Binding PrsID}" Visibility="Collapsed"/>
                            <TextBlock Name="txtNachName" Text="{Binding Nachname}" Grid.Column="1" Margin="5,0,0,0"/>
                            <TextBlock Name="txtName" Text="{Binding Name}" Grid.Column="2" Margin="5,0,0,0"/>
                        </Grid>

                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding PersonTyp}" Value="Zusatzperson">
                                <Setter TargetName="txtPrsId" Property="Foreground" Value="Green"/>
                                <Setter TargetName="txtName" Property="Foreground" Value="Green"/>
                                <Setter TargetName="txtNachName" Property="Foreground" Value="Green"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding PersonTyp}" Value="Inaktiv">
                                <Setter TargetName="txtPrsId" Property="Foreground" Value="Red"/>
                                <Setter TargetName="txtName" Property="Foreground" Value="Red"/>
                                <Setter TargetName="txtNachName" Property="Foreground" Value="Red"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding ShowPrsId}" Value="True">
                                <Setter TargetName="txtPrsId" Property="Visibility" Value="Visible"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding NameDisplay}" Value="VornameName">
                                <Setter TargetName="txtName" Property="Grid.Column" Value="1"/>
                                <Setter TargetName="txtNachName" Property="Grid.Column" Value="2"/>
                            </DataTrigger>
                        </DataTemplate.Triggers>

                    </DataTemplate>

                    <DataTemplate DataType="{x:Type bs:Abteilung}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Name}"/>
                        </StackPanel>
                    </DataTemplate>

                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
        
    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="White" Offset="0"/>
                <GradientStop Color="White" Offset="0.6"/>
                <GradientStop Color="#FFEDEDED" Offset="1"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </Window.Background>
    
    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        
        <TextBlock Text="Person hinzufügen" FontSize="22" FontWeight="Thin" Foreground="#E1000000" Margin="50,-5,0,25"/>

        
        
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <CheckBox IsChecked="{Binding IsEmptyRow}"  Margin="40,0,0,10" x:Name="chkEmptyRow" VerticalAlignment="Bottom">
                <TextBlock Text="Leere Zeile einfügen"/>
            </CheckBox>

            <CheckBox Grid.Column="1" Margin="40,0,0,10" x:Name="chkNewPerson"
                  IsChecked="{Binding IsNewPerson}" VerticalAlignment="Bottom"
                  IsEnabled="{Binding IsChecked, ElementName=chkEmptyRow, Converter={StaticResource boolInvert}}" >
                <TextBlock Text="Neue Person erfassen"/>
            </CheckBox>

            
            
            
        </Grid>
        
        <Grid Grid.Row="3" Margin="20,0,20,0" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <GroupBox Header="Person">
                <Grid>
                    <Grid Visibility="{Binding IsChecked, ElementName=chkNewPerson, Converter={StaticResource boolVis}}" Margin="0,0,20,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Text="{x:Static p:Resources.Vorname}" Grid.Row="1" Margin="0,0,5,0"/>
                        <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding SelectedPerson.Name, UpdateSourceTrigger=PropertyChanged}"/>

                        <TextBlock Text="{x:Static p:Resources.Nachname}" Grid.Row="2" Margin="0,0,5,0"/>
                        <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding SelectedPerson.Nachname, UpdateSourceTrigger=PropertyChanged}"/>
                    </Grid>

                    <Grid Visibility="{Binding IsChecked, ElementName=chkNewPerson, Converter={StaticResource boolInvertVis}}"
                          IsEnabled="{Binding IsEmptyRow, Converter={StaticResource boolInvert}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <CheckBox Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" IsChecked="{Binding ShowAllPersonen}" Margin="15,0,0,5">
                            <TextBlock Text="{x:Static p:Resources.ShowAllPersonen}" Margin="0"/>
                        </CheckBox>
                        
                        <TextBox Grid.Row="1" FontSize="10" Text="{Binding FilterString, UpdateSourceTrigger=PropertyChanged}" FontWeight="Heavy" Margin="15,0,25,5"/>
                        <ListBox Margin="20,0,20,0" BorderThickness="0,0,1,0" Grid.Row="2"
                             ItemsSource="{Binding Personen}"
                             SelectedItem="{Binding SelectedPerson}"
                             />
                    </Grid>
                    
                </Grid>
            </GroupBox>


            <GroupBox Grid.Column="1" Margin="20,0,20,0" Header="Team">
                <ListBox BorderThickness="0,0,1,0"
                             ItemsSource="{Binding Abteilungen}"
                             SelectedItem="{Binding SelectedAbteilung}"
                             DisplayMemberPath="Name"/>
            </GroupBox>
        </Grid>


            <TextBlock Grid.Row="4" Margin="20,20,10,00" TextWrapping="Wrap" Text="{x:Static p:Resources.PersonEinfuegenDescription1}"/>

            <StackPanel Grid.Column="1" Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,20,30,20">
                <Button MinWidth="60" Margin="5" IsDefault="True" 
                    Command="{Binding OkCommand}">
                    <TextBlock Text="OK"/>
                </Button>
                <Button MinWidth="60" Margin="5" IsCancel="True" >
                    <!--Command="{Binding CancelCommand}"-->
                    <TextBlock Text="Abbrechen"/>
                </Button>
            </StackPanel>
            
        <!--</Grid>-->
        
    </Grid>
</c:WindowExt>
